package com.ruoyi.kaifa.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.kaifa.domain.AStanding;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kaifa.domain.ATag;
import com.ruoyi.kaifa.service.IATagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标签Controller
 * 
 * @author ruoyi
 * @date 2024-09-30
 */
@RestController
@RequestMapping("/kaifa/tag")
public class ATagController extends BaseController
{
    @Autowired
    private IATagService aTagService;

    /**
     * 查询标签列表
     */
    @PreAuthorize("@ss.hasPermi('kaifa:tag:list')")
    @GetMapping("/list")
    public TableDataInfo list(ATag aTag)
    {
        startPage();
        List<ATag> list = aTagService.selectATagList(aTag);
        return getDataTable(list);
    }

    /**
     * 导出标签列表
     */
    @PreAuthorize("@ss.hasPermi('kaifa:tag:export')")
    @Log(title = "标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ATag aTag)
    {
        List<ATag> list = aTagService.selectATagList(aTag);
        ExcelUtil<ATag> util = new ExcelUtil<ATag>(ATag.class);
        util.exportExcel(response, list, "标签数据");
    }

    /**
     * 获取标签详细信息
     */
    @PreAuthorize("@ss.hasPermi('kaifa:tag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aTagService.selectATagById(id));
    }

    /**
     * 新增标签
     */
    @PreAuthorize("@ss.hasPermi('kaifa:tag:add')")
    @Log(title = "标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ATag aTag)
    {
        return toAjax(aTagService.insertATag(aTag));
    }

    /**
     * 修改标签
     */
    @PreAuthorize("@ss.hasPermi('kaifa:tag:edit')")
    @Log(title = "标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ATag aTag)
    {
        return toAjax(aTagService.updateATag(aTag));
    }

    /**
     * 删除标签
     */
    @PreAuthorize("@ss.hasPermi('kaifa:tag:remove')")
    @Log(title = "标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aTagService.deleteATagByIds(ids));
    }



    /**
     * 远程查询身份信息
     */
    @PreAuthorize("@ss.hasPermi('kaifa:standing:getTagsByName')")
    @GetMapping("/getTagsByName")
    public TableDataInfo getTagsByName(@RequestParam("name") String name){
        List<ATag> atagsList  =  aTagService.getTagsList(name);
        return getDataTable(atagsList);
    }


    /**
     * 远程查询身份信息
     */
    @PreAuthorize("@ss.hasPermi('kaifa:standing:getShowTag')")
    @GetMapping("/getShowTag")
    public TableDataInfo getShowTag(@RequestParam("ids") Long[] ids){
        List<ATag> atagsList  =  aTagService.getTagsByIdList(ids);
        return getDataTable(atagsList);
    }
}
